/**
 * Copyright (c) 2018
 * Author: fan.z
 */
package bm.sg.net.ssf.util;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * <pre>
 * 类说明：
 * 
 * Modify Information:
 * Author         Date         Description
 * ============ =========== ============================
 * fan.z        2018-11-03    Create this file
 * </pre>
 * 
 * @category bm.sg.net.gt.util.FileWriteUtil
 */
public class FileWriteUtil {

    /**
     * <pre>
     * 功能描述:写入文件
     * </pre>
     * 
     * @param path
     * @param content 
     * @param append: true = append file
     */
    public static void createByWriter(String path, String content, boolean append) {
        try {
            File file = new File(path);

            // if file doesnt exists, then create it
            if (!file.exists()) {
                file.createNewFile();
            }

            // true = append file
            FileWriter fw = new FileWriter(file.getAbsoluteFile());
            BufferedWriter bw = new BufferedWriter(fw);
            bw.write(content);
            bw.close();
            //System.out.println("Done");

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
